<?php

namespace App\Http\Middleware;

use App\Exceptions\ApiException;
use App\Models\User;
use Closure;
use Dingo\Api\Routing\Helpers;

class SellerAuth
{
    use Helpers;

    public function handle($request, Closure $next)
    {
        //判断用户角色
        if (app()->environment('production') && $this->user->role !== User::SELLER) {
            throw new ApiException(trans('api.operation_rejected'), 403);
        }

        return $next($request);
    }
}
